﻿using SuperSocket.Facility.Protocol;//
using SuperSocket.Common;
using SuperSocket.SocketBase.Protocol;
using System;//

namespace TcpServer.ClientServer
{
    public class ClientServerReceiveFilter : BeginEndMarkReceiveFilter<StringRequestInfo>
    {
        //开始和结束标记也可以是两个或两个以上的字节
        private readonly static byte[] BeginMark = new byte[] { (byte)'<' };
        private readonly static byte[] EndMark = new byte[] { (byte)'>' };

        public ClientServerReceiveFilter()
        : base(BeginMark, EndMark) //传入开始标记和结束标记
        {

        }

        protected override StringRequestInfo ProcessMatchedRequest(byte[] readBuffer, int offset, int length)
        {
            //TODO: 通过解析到的数据来构造请求实例，并返回
            return new StringRequestInfo("", System.Text.Encoding.UTF8.GetString(readBuffer).Substring(1,readBuffer.Length-2), new string[] { });//key 和 param 为空,过滤掉起始和结尾符号
        }


    }
}
